//
//  HJZStatusTableViewCell.m
//  HJZWeiBo
//
//  Created by 蒋晨成 on 16/6/1.
//  Copyright © 2016年 蒋晨成. All rights reserved.
//

#import "HJZStatusTableViewCell.h"

@interface HJZStatusTableViewCell ()



@end

@implementation HJZStatusTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"status";
    HJZStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[HJZStatusTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
}

#pragma mark - 重写setFrame:方法

- (void)setFrame:(CGRect)frame
{
    frame.origin.x = HJZStatusPadding * 0.5;
    frame.size.width -= HJZStatusPadding;
    frame.origin.y += HJZStatusPadding * 0.5;
    frame.size.height -= HJZStatusPadding * 0.5;
    
    [super setFrame:frame];
}

#pragma mark - 初始化

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectedBackgroundView = [[UIView alloc] init];
        
        // 初始化微博的topView
        [self setupTopView];
        
        // 初始化微博工具条
        [self setupToolBar];
    }
    return self;
}

/**
 *  初始化微博的topView
 */
- (void)setupTopView
{
    HJZStatusTopView *topView = [[HJZStatusTopView alloc] init];
    [self.contentView addSubview:topView];
    self.topView = topView;
}

/**
 *  初始化微博工具条
 */
- (void)setupToolBar
{
    HJZStatusToolBar *statusToolBar = [[HJZStatusToolBar alloc] init];
    
    [self.contentView addSubview:statusToolBar];
    self.statusToolBar = statusToolBar;
}

#pragma mark - 设置数据

- (void)setStatusFrame:(HJZStatusFrame *)statusFrame
{
    _statusFrame = statusFrame;
    
    // 设置原创微博数据和frame
    [self setupTopViewData];
    
    // 设置微博工具条数据和frame
    [self setupToolBarData];
}

/**
 *  设置原创微博数据和frame
 */
- (void)setupTopViewData
{
    HJZStatusFrame *statusFrame = self.statusFrame;
    
    // 传递数据和布局
    self.topView.statusFrame = statusFrame;
    self.topView.frame = statusFrame.originalViewF;
}

/**
 *  设置微博工具条数据和frame
 */
- (void)setupToolBarData
{
    self.statusToolBar.frame = self.statusFrame.statusToolBarF;
    self.statusToolBar.status = self.statusFrame.status;
}



@end
